<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2019/4/7
 * Time: 20:53
 */

namespace common\sources\write\cashrecord;

use common\models\craftsman\CashRecord;
use Yii;

class CashRecordAccess implements ICashRecordAccess
{
    public function addCashRecord($data)
    {
        return Yii::$app->db->createCommand()->insert('business_cash_record', [
            'bus_id' => $data['bus_id'],
            'money' => $data['money'],
            'account_num' => $data['account_num'],
            'ww_verify_img' => $data['ww_verify_img'],
            'username' => $data['username'],
            'cash_status' => $data['cash_status'],
            'remark' => $data['remark'],
            'arrival_money' => $data['arrival_money'],
            'serial_num' => $data['serial_num'],
            'create_time' => time()
        ])->execute();
    }

    public function modifyCashRecord($data)
    {
        $sql = 'UPDATE ' . CashRecord::tableName() . ' SET cash_status = :cash_status,update_time = :update_time WHERE id = :id ';
        return Yii::$app->db->createCommand($sql)
            ->bindValues([
                ':cash_status' => $data['cash_status'],
                ':update_time' => time(),
                ':id' => $data['id']
            ])->execute();
    }
}